﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace YXShop.Web.admin.shop
{
    public partial class shop_domain_name : System.Web.UI.Page
    {
        YXShop.BLL.Shop.Shop shopBll = new YXShop.BLL.Shop.Shop();
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                YXShop.Common.PromptInfo.Popedom("013004001");
                if (ChangeHope.WebPage.PageRequest.GetFormString("Option") != string.Empty && ChangeHope.WebPage.PageRequest.GetFormString("id") != "")
                {
                    string types = Request["Option"].Trim();
                    string id = ChangeHope.WebPage.PageRequest.GetFormString("id");
                    if (types == "del")
                    {
                        YXShop.Common.PromptInfo.Popedom("013004003", "对不起，您没有权限进行删除");
                        shopBll.Delete(Convert.ToInt32(id));
                    }
                    if (types == "delAll")
                    {
                        YXShop.Common.PromptInfo.Popedom("013004003", "对不起，您没有权限进行删除");
                        shopBll.DeleteAll(id);
                    }
                    Response.End();
                    return;
                }
                this.lblList.Text = GetList();
            }

        }
        protected string GetList()
        {
            ChangeHope.WebPage.Table table = new ChangeHope.WebPage.Table();
            ChangeHope.DataBase.DataByPage dataPage = shopBll.GetList(" and state=1 ");
            table.AddHeadCol("", "<input id=\"chall\" type=\"checkbox\" onclick=\"SelectAll(chall)\" />全选");
            table.AddHeadCol("","域名");
            table.AddHeadCol("","店铺编号");
            table.AddHeadCol("","店铺名称");
            table.AddHeadCol("","域名状态");
            table.AddHeadCol("","申请日期");
            table.AddHeadCol("","操作");
            table.AddRow();
            if(dataPage.DataReader!=null)
            {
                while(dataPage.DataReader.Read())
                {

                    table.AddCol("<input id=\"cbTm\"  type=\"checkbox\" value=\"" + dataPage.DataReader["sid"].ToString() + "\" />");
                    table.AddCol(dataPage.DataReader["twodomainname"].ToString());
                    table.AddCol("shop" + dataPage.DataReader["shopnum"].ToString());
                    table.AddCol(dataPage.DataReader["shopname"].ToString());
                    table.AddCol(dataPage.DataReader["attribute"].ToString().Split(',')[5]=="1" ? "已审核":"未审核");
                    table.AddCol(dataPage.DataReader["addtime"].ToString());
                    string url = YXShop.TemplateAction.Common.UrlStr("shop_domain_edit", "shopId=" + dataPage.DataReader["sid"].ToString(), "admin/shop/");
                    table.AddCol("<a href=\""+url+"\">编辑</a>&nbsp;<a href=\"#\" onclick='Del(" + dataPage.DataReader["sid"] + ")'>删除</a>");
                    table.AddRow();
                }
            }
            string view = table.GetTable() + dataPage.PageToolBar;
            dataPage.Dispose();
            dataPage = null;
            return view;
        }

        protected void butSearch_Click(object sender, EventArgs e)
        {
            this.lblList.Text = GetList();
        }
    }
}
